//
//  MyWealthViewController.m
//  Socrates
//
//  Created by shy on 15/4/12.
//  Copyright (c) 2015年 shy. All rights reserved.
//

#import "MyWealthViewController.h"

typedef enum {
    kWealth_total_item = 0,
    kWealth_created_item,
    kWealth_joined_item,
    kWealth_comment_item,
    kWealth_shared_item,
    kWealth_Num,
} WealthItems;

typedef enum {
    kWealth_total_section = 0,
    kWealth_others_section,
    kWealth_Section_Num,
} WealthSections;

static const int kLimitationRowHeight = 40;

@implementation MyWealthViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    //here is the bug caused.
    self.navigationItem.title = @"首页";
    self.view.backgroundColor = [UIColor colorWithRed:239/255. green:239/255. blue:244/255. alpha:1.];
    self.tableView.separatorInset = UIEdgeInsetsMake(0, 23, 0, 23);
    self.tableView.scrollEnabled = NO;
    self.wealthHint.font = [UIFont systemFontOfSize:13.];
    self.wealthHint.textColor = [UIColor grayColor];
    self.wealthHint.text = @"积分仅限在识趣儿APP内部使用，不提供任何提现服务。";
    self.wealthHint.textAlignment = NSTextAlignmentCenter;
    // Do any additional setup after loading the view, typically from a nib.
}

- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section {
    return 20;
}

- (UIView*)tableView:(UITableView*)tableView viewForHeaderInSection:(NSInteger)section {
    UIView *view = [[UIView alloc] initWithFrame:CGRectMake(0, 0, [UIScreen mainScreen].bounds.size.width, 20)];
    view.backgroundColor = [UIColor whiteColor];
    UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(23, 14, [UIScreen mainScreen].bounds.size.width - 46, 14)];
    label.text = @"我的识趣儿积分";
    label.font = [UIFont systemFontOfSize:12.];
    label.textColor = [UIColor grayColor];
    [view addSubview:label];
    return view;
}

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
    switch ([indexPath row]) {
        case kWealth_total_item:
            return 33;
        default:
            return kLimitationRowHeight;
    }
}

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
    return 1;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    return kWealth_Num;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    NSString *cellIdentifier = @"JoinedCellIdentifier";
    UITableViewCell *cell = [self.tableView dequeueReusableCellWithIdentifier:cellIdentifier];
    if (!cell) {
        cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellIdentifier];
    }
    UILabel *score = [[UILabel alloc] initWithFrame:CGRectMake([UIScreen mainScreen].bounds.size.width - 123, 0, 100, 40)];
    score.textAlignment = NSTextAlignmentRight;
    score.textColor = [UIColor colorWithRed:241/255. green:194/255. blue:50/255. alpha:1.];
//    score.backgroundColor = [UIColor purpleColor];
    [cell addSubview:score];
    switch ([indexPath row]) {
        case kWealth_total_item:
            [cell addSubview:score];
            score.font = [UIFont systemFontOfSize:22.];
            score.text = @"15000";
            break;
        case kWealth_created_item:
            cell.textLabel.text = @"发布活动";
            score.font = [UIFont systemFontOfSize:18.];
            score.text = @"+2000";
            break;
        case kWealth_joined_item:
            cell.textLabel.text = @"参与活动";
            score.font = [UIFont systemFontOfSize:18.];
            score.text = @"+3000";
            break;
        case kWealth_comment_item:
            cell.textLabel.text = @"评价活动";
            score.font = [UIFont systemFontOfSize:18.];
            score.text = @"+2000";
            break;
        case kWealth_shared_item:
            cell.textLabel.text = @"分享活动";
            score.font = [UIFont systemFontOfSize:18.];
            score.text = @"+2000";
            break;
        default:
            break;
    }
    return cell;
}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
    
}
@end
